// Copy assignment.

#include <iostream>
using namespace std;

class Human {
	public:
		// parameterless constructor
		Human( int age=0, const char* name="wuming" ) {
			cout << "This function has been called" << endl;
			this->age = age;
			this->name = name;
		}
		// Copy constructor
		// If you provide a copy constructor, you must to manipulate the variables yourself.
		Human( const Human& that ) {
			cout << "called" << endl;
			// [ int age ]
			// [ string name ]
			this->age = that.age;
			this->name = that.name;
		}
		// If you don't provide a operator function, the compiler will.
/*		Human& operator=( const Human& that ) {
			this->age = that.age;
			this->name = that.name;
			return *this;
		}*/
		void getinfo( ) {
			cout << "name : " << name << endl;
			cout << "age : " << age << endl;
		}
	private:
		int age;
		string name;
};

// designer
// ------------------------------------------------------------------
// user

int main( void ) { 
	Human h( 22, "zhangei" );
	Human h3(h);
	
	Human h4;
	h4 = h3;	// h4.operator = (h3)
	h4.getinfo( );

	return 0;
}

